/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring.dao;


import com.spring.entidades.Registrador;
import com.spring.entidades.TipoReg;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Usuario23
 */
@Repository
public class tiporegDAO extends HibernateDaoSupport{

    @Autowired
    public tiporegDAO(SessionFactory sessionFactory) {
        
    
        super.setSessionFactory(sessionFactory);
   }
   
     public List<TipoReg> getListarTipoRegistrador(){
        return getHibernateTemplate().find("SELECT t FROM TipoReg t");
    }

       
     public boolean insertarTipoRegistrador(TipoReg t)
    {
        boolean b= false;
        
        try{
            getHibernateTemplate().saveOrUpdate(t);
            b=true;
            
        } catch(Exception e){
            e.printStackTrace();
        }
         return b;
         
    }

   
    
    public TipoReg buscarTipoRegistrador(String codigo){
          
        TipoReg t= getHibernateTemplate().get(TipoReg.class, codigo);
        return t;
                
    }
    
    
       public boolean EliminarTipoRegistrador(String codigo )
    {
        boolean b= false;
        
        try{
            TipoReg t= getHibernateTemplate().get(TipoReg.class, codigo);
            getHibernateTemplate().delete(t);
            b=true;
            
        } catch(Exception e){
            e.printStackTrace();
            b=false;
        }
         return b;
         
    }

}
    